#pragma once

#include <iostream>
#include <vector>
#include <windows.h>
#include <gl/gl.h>
#include <cg/cg.h> 
#include "Renderer.h"
#include "TextureManager.h"

class CModel
{
private:
	vector<float3> m_vPos;
	vector<float3> m_vNormal;
	vector<float2> m_vTexCoord;
	vector<CRenderer::SVert> m_vVertices;

	int m_iVerticesCount;

	CTexture* m_pTexture;
	bool m_bMultiTextured;		//set if model has multiple textures
	GLuint m_uiVBOVertices;		//model VBO ID
	GLuint m_uiVBOIndices;		//model IBO ID

	CGprogram m_cgProgVertex;
	CGprogram m_cgProgFragment;

	CRenderer::SVert* m_pVertBuffer;
	unsigned short* m_pIndBuffer;

	static CRenderer* m_pRenderer;
public:
	CModel(void);
	CModel(bool bMultiTextured);
	~CModel(void);

	int ProcessLine(FILE* fileModel);
	int LoadTexture(const char *szFileName);
	int LoadModel(const char* szFileName);
	int CreateTexBox(float fXS, float fYS, float fZS, float fXTS, float fYTS, float fZTS);
	int LoadShader(const char* szFileName);

	void SetShaderParamd3(const char* szParamName, double3 d3Param);
	void SetShaderParamd(const char* szParamName, double dParam);
	void SetTextureParamui(const char* szParamName, unsigned int uiTexName);
	int DrawModel();

	int GetVerticesCount() { return m_iVerticesCount; }

	static void SetRenderer(CRenderer* pRenderer) { m_pRenderer = pRenderer; };
};
